package org.jeecg.modules.zcgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.zcgl.entity.CcqtgbLog;
import org.jeecg.modules.zcgl.mapper.CcqtgbLogMapper;
import org.jeecg.modules.zcgl.service.ICcqtgbLogService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Description: 调用三峡银行接口记录
 * @Author: jeecg-boot
 * @Date:   2021-02-01
 * @Version: V1.0
 */
@Service
public class CcqtgbLogServiceImpl extends ServiceImpl<CcqtgbLogMapper, CcqtgbLog> implements ICcqtgbLogService {

    @Override
    public CcqtgbLog selectByCompanyIdAndSucceedAndDateAndType(String companyId, Integer izSucceed, Date date, Integer type) {
        CcqtgbLog log = new CcqtgbLog();
        log.setCompanyId(companyId);
        log.setIzSucceed(izSucceed);
        log.setType(type);
        QueryWrapper<CcqtgbLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().apply("DATE(date) = DATE('" + DateUtils.formatDate(date, DateUtils.DATE_FORMAT) + "')");
        queryWrapper.last("LIMIT 1");
        queryWrapper.setEntity(log);
        return baseMapper.selectOne(queryWrapper);
    }
}
